mwifiex: Fix heap overflow in mwifiex_uap_parse_tail_ies()
authorTakashi Iwai <tiwai@suse.de>
Fri, 31 May 2019 13:18:41 +0000 (15:18 +0200)
committerSalvatore Bonaccorso <carnil@debian.org>
Thu, 18 Jul 2019 22:23:17 +0000 (23:23 +0100)
commit3cdfec422fbe6659f9067f8bd8dfbd2eb84283d6
tree0467299ad6a77fcc3a3ac1f853433f7ad0d7764b
parentc4254b5f1e6c3f4c3ec050aa90faea9f74150f0e
mwifiex: Fix heap overflow in mwifiex_uap_parse_tail_ies()

A few places in mwifiex_uap_parse_tail_ies() perform memcpy()
unconditionally, which may lead to either buffer overflow or read over
boundary.

This patch addresses the issues by checking the read size and the
destination size at each place more properly.  Along with the fixes,
the patch cleans up the code slightly by introducing a temporary
variable for the token size, and unifies the error path with the
standard goto statement.

Reported-by: huangwen <huangwen@venustech.com.cn>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
[bwh: Backported to 4.19: adjust context]

Gbp-Pq: Topic bugfix/all
Gbp-Pq: Name mwifiex-fix-heap-overflow-in-mwifiex_uap_parse_tail_.patch
drivers/net/wireless/marvell/mwifiex/ie.c